function RequestFactory() {
	this.Requests = [];
}

RequestFactory.prototype.CreateRequest = function(obj, act_type, page_type, html) {
    var req = new Request(obj, act_type, page_type, html);
    this.Requests.push(req);
    return req;
}

RequestFactory.prototype.toString = function() {
    var xml = '<?xml version="1.0" encoding="utf-8" ?>';
    xml += '<pack>';
    for (var i = 0; i < this.Requests.length; i++) 
        xml += this.Requests[i].toString();
    xml += '</pack>';
    return xml;
}

function Request(obj, act_type, page_type, html) {
    var dt = new Date();

    this.ID = dt.getTime();
    this.Obj = obj;
    this.ActType = act_type;
	this.PageType = page_type;
    this.HTML = html;

    this.Sections = [];
}

Request.prototype.CreateSection = function(type, name, value) {
    var sec = new RequestSection(type, name, value);
    this.Sections.push(sec);
    return this;
}

Request.prototype.toString = function() {
    var xml =
		'<request id="' + this.ID +
		'" obj="' + this.Obj +
		'" act_type="' + this.ActType +
		'" page_type="' + this.PageType +
		'" html="' + this.HTML + '">';
    for (var i = 0; i < this.Sections.length; i++)
        xml += this.Sections[i].toString();
    xml += '</request>';
    return xml;
}

function RequestSection(type, name, value) {
    this.Type = type;
    this.Name = name;
    this.Value = String(value)
		.replace(/\x0A/g, '&#010;')
		.replace(/\x0D/g, '&#013;')
		.replace(/"/g, '&#034;')
		.replace(/&/g, "&#038;")
		.replace(/'/g, "&#039;")
		.replace(/</g, "&#060;")
		.replace(/>/g, "&#062;");
}

RequestSection.prototype.toString = function() {
    return '<' + this.Type + ' name="'+ this.Name +'" value="'+ this.Value +'" />';
}

//---------------------------------------------------------

function WaitBox(selector)
{
	this.box = $(selector);
}

WaitBox.prototype.show = function(x, y)
{
	this.box.css("left", x).css("top", y).show();
}

WaitBox.prototype.hide = function(x, y)
{
	this.box.hide();
}

